package com.seat.service.impl;


import com.seat.mapper.UserMapper;
import com.seat.pojo.dto.RegisterDTO;
import com.seat.pojo.dto.UpdateEmailDTO;
import com.seat.pojo.dto.UpdateNicknameDTO;
import com.seat.pojo.entrity.User;
import com.seat.service.UserService;
import com.seat.utils.Md5Util;
import com.seat.utils.ThreadLocalUtil;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
@Slf4j
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User findByUserName(String username) {
        User u = userMapper.findByUserName(username);
        return u;
    }

    @Override
    public void register(RegisterDTO register) {
        //加密
        String md5String = Md5Util.getMD5String( register.getPassword());
        register.setPassword(md5String);
        //添加
        userMapper.add(register);
    }

    @Override
    public void UpdatePassword(String newPassword) {
        userMapper.UpdatePassword(newPassword);
    }

    @Override
    public void UpdateNickname(UpdateNicknameDTO updatePIc) {
        userMapper.UpdateNickname(updatePIc);
    }

    @Override
    public void updateEmail(UpdateEmailDTO updateEmail) {
        userMapper.updateEmail(updateEmail);
    }

    @Override
    public void UpdatePic(String picUrl,String username) {

        userMapper.updatePic(picUrl,username);
    }


}
